#!/bin/sh
main()
{
. $DOCUMENT_ROOT/apps/home/header.tpl.sh
header_html
cat <<'EOF'
<script>
$(function(){
  $('#post_chpass').on('submit', function(e){
    e.preventDefault();
    var data = "app=password&"+$(this).serialize();
    var url = 'index.cgi';
    Ha.common.ajax(url, 'json', data, 'post', 'ajax-fluid');
  });
});
</script>
EOF
cat <<EOF
		<div class="pure-g">
			<div class="l-box-lrg pure-u-1 pure-u-md-1-2">
				<h3>管理员用户名和密码修改</h3>
				<form class="pure-form pure-form-stacked" id="post_chpass">
					<fieldset>

						<label for="name">User Name</label>
						<p>admin</p>

						<label for="password">Password</label>
						<input type="password" name="password" value="">
						<label for="password">Password Comfirm</label>
						<input type="password" name="password_cf" value="">

						<input type="hidden" name="action" value="post_chpass">
						<input type="hidden" name="app" value="password">
						<button type="submit" class="pure-button">修改</button>

					</fieldset>
				</form>
				<br/>
				<br/>
			</div>
			<div class="l-box-lrg pure-u-1 pure-u-md-1-2">
				<div class="content">
				<h3>更改密码<h3>
				<p>需要重复输入密码确认.</p>
				</div>
			</div>
		</div>
EOF
footer_html keep_bottom
}
post_chpass()
{
if
[ "$FORM_password" = "$FORM_password_cf" ]
then
passwd admin <<EOF >/dev/null 2>&1
$FORM_password
$FORM_password_cf
EOF
echo "密码修改成功!!" | main.sbin output_json 0
else
echo "两次输入密码不同!" | main.sbin output_json 1
EOF
fi
}

lang=`main.sbin get_client_lang`
eval `cat $DOCUMENT_ROOT/apps/$FORM_app/i18n/$lang/i18n.conf`
if
[ $is_main_page = 1 ]
then
main
elif [ -n "$FORM_action" ]
then
$FORM_action
fi
